<template>
	<view class="custom_news_list_item" v-if="item.newsId">
		<view v-if="item.content" class="item_view">
			<view class="item_content">
				<view class="item_title ot" v-if="item.title">{{ item.title }}</view>
				<view class="item_desc ot" v-if="item.desc">{{ item.desc }}</view>
				<view class="item_aside">{{ item.source }} - {{ item.createTime }}</view>
				<view class="item_tags">
					<navigator :url="'../../pages/search/q?k=' + tag.text" v-for="(tag, index) in item.tags"><custom-tag :item="{ ...tag, type: 'primary' }"></custom-tag></navigator>
				</view>
			</view>
			<view class="item_image ot" @click="imageViewHandle">
				<view class="item_image_tip">点击查看大图</view>
				<image
					:src="image.url"
					v-for="(image, index) in item.images"
					:lazy-load="true"
					mode="aspectFill"
					style="width:100%;height:320rpx;"
					
				></image>
			</view>
			<view class="item_content">
				<view class="item_more_content" v-if="item.content">{{ item.content }}</view>
			</view>
		</view>
		<navigator v-else :url="'../index/view?id=' + item.newsId">
			<view class="item_content">
				<view class="item_title" v-if="item.title && !item.content">{{ item.title }}</view>
				<view class="item_desc" v-if="item.desc && !item.content">{{ item.desc }}</view>
				<view class="item_aside" v-if="!item.content">{{ item.source }} - {{ item.createTime }}</view>
			</view>
		</navigator>
		<view class="item_image" v-if="!item.content && item.images && item.images.length > 0" @click="imageViewHandle">
			<view class="item_image_tip">点击查看大图</view>
			<image
				:src="image.url"
				v-for="(image, index) in item.images"
				:lazy-load="true"
				mode="aspectFill"
				style="width:100%;height:240rpx;flex:1;"
				
			></image>
		</view>

		<custom-news-list-tools :item="item"></custom-news-list-tools>
	</view>
</template>

<script>
export default {
	name: 'custom-news-list-item',
	props: {
		item: {
			type: Object,
			default() {
				return {};
			}
		}
	},
	data() {
		return {};
	},
	methods: {
		imageViewHandle(e) {
			let images = [];
			this.$props.item.images.forEach(img => images.push(img.url));
			uni.previewImage({
				current: 0,
				urls: images
			});
		}
	}
};
</script>

<style lang="less">
.custom_news_list_item {
	background-color: #ffffff;
	border-radius: 10rpx;
	margin: 10rpx 0;
	height: 100%;
	.item_view {
		overflow: hidden;
		height: 100%;
		.item_image {
			display: flex;
			justify-content: center;
			align-items: center;
			position:relative;
			&.ot {
				flex-direction: column;
				height: 100%;
				margin: 0 10rpx;
				image {
					margin: 0 0 10rpx 0;
					&:last-child {
						margin: 0;
					}
				}
			}
			.item_image_tip{
				position:absolute;
				top:16rpx;
				right:20rpx;
				background-color: rgba(0,0,0,.5);
				color:#FFFFFF;
				border-radius: 40rpx;
				font-size: 20rpx;
				padding:6rpx 16rpx;
			}
			image {
				flex: 1;
				width: 100%;
				height: 100%;
				margin-right: 20rpx;
				&:last-child {
					margin-right: 0rpx;
				}
				background-color: #666666;
			}
		}
		.item_content {
			padding: 20rpx;
			.item_title {
				font-size: 32rpx;
				&.ot {
					font-size: 48rpx;
					font-weight: 700;
				}
			}
			.item_desc {
				font-size: 24rpx;
				padding: 10rpx 0;
				color: #999999;
				&.ot {
					font-size: 32rpx;
				}
			}
			.item_aside {
				font-size: 20rpx;
				color: #ccc;
			}
			.item_tags {
				display: flex;
				padding: 20rpx 0;
				navigator {
					margin: 0 10rpx;
					&:first-child {
						margin-left: 0;
					}
					&:last-child {
						margin-right: 0;
					}
				}
			}
			.item_more_content {
				line-height: 64rpx;
				text-indent: 64rpx;
				padding: 20rpx 0;
			}
		}
	}
	navigator {
		//border-radius: 10rpx;
		//border-bottom:1rpx #efefef solid;
		overflow: hidden;
		height: 100%;

		.item_content {
			padding: 20rpx;
			.item_title {
				font-size: 32rpx;
				&.ot {
					font-size: 48rpx;
					font-weight: 700;
				}
			}
			.item_desc {
				font-size: 28rpx;
				padding: 10rpx 0;
				color: #999999;
				&.ot {
					font-size: 32rpx;
				}
			}
			.item_aside {
				font-size: 20rpx;
				color: #ccc;
			}
			.item_more_content {
				line-height: 64rpx;
			}
		}
	}
	.item_image {
		display: flex;
		justify-content: center;
		align-items: center;
		margin: 0 0 20rpx 0;
		position:relative;
		&.ot {
			flex-direction: column;
			height: 100%;
			margin: 0 10rpx;
			image {
				margin: 0 0 10rpx 0;
				&:last-child {
					margin: 0;
				}
			}
		}
		.item_image_tip{
			position:absolute;
			top:16rpx;
			right:20rpx;
			background-color: rgba(0,0,0,.5);
			color:#FFFFFF;
			border-radius: 40rpx;
			font-size: 20rpx;
			padding:6rpx 16rpx;
		}
		image {
			flex: 1;
			width: 100%;
			height: 100%;
			margin-right: 20rpx;
			&:last-child {
				margin-right: 0rpx;
			}
			background-color: #666666;
		}
	}
}
</style>
